package com.clkj.mobileinspector.ui.adapter;

import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import com.clkj.mobileinspector.R;
import com.clkj.mobileinspector.model.bean.QuerySuccessBean;
import com.clkj.mobileinspector.utils.JsonUtils;
import com.lws.basic.utils.common.MyLogger;
import com.lws.basic.utils.common.MyToast;
import com.lws.basic.utils.common.TimeUtils;

import java.util.List;

import androidx.annotation.Nullable;

import static com.clkj.mobileinspector.utils.JsonUtils.queryGetFiled;


/**
 * @author 松
 * 2020/9/27 10:20
 */
public class SafeguardRigthRecordAdapter extends BaseQuickAdapter<QuerySuccessBean.DataBean.DataListBean, BaseViewHolder> {
    public SafeguardRigthRecordAdapter(@Nullable List<QuerySuccessBean.DataBean.DataListBean> data) {
        super(R.layout.rv_safeguard_rigth_record,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, QuerySuccessBean.DataBean.DataListBean item) {
        try {
            helper.setText(R.id.tv_1, queryGetFiled(item.getFieldValues(), "policename"));
            String policetype= JsonUtils.queryGetFiled(item.getFieldValues(), "policetype");
            if (!TextUtils.isEmpty(policetype)){
                  if (policetype.equals("1")){
                      helper.setText(R.id.tv_2, "民警");

                  }else {
                      helper.setText(R.id.tv_2,"辅警" );

                  }
            }
            helper.setText(R.id.tv_3, JsonUtils.queryGetFiled(item.getFieldValues(), "offendername"));

            helper.setText(R.id.tv_4, TimeUtils.yyyyMMdd(JsonUtils.queryGetFiled(item.getFieldValues(), "createdate")));

        }catch (Exception e){
            MyToast.show(e.getMessage());
            MyLogger.e(e.getMessage());
        }

    }
}
